﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VTLive.Models;

namespace VTLive.Controllers
{
    public class BaseController : Controller
    // Þessi controller sér um það að sýna sidebar þar sem það á við
    {
        public int m_iUserID { get; set; }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        //Kemur því þannig fyrir að smiður BaseController sé keyrður í hvert skipti sem síðan hleðst inn
        {
            base.OnActionExecuting(filterContext);

            IQueryable<Station> OwnedStations = null;
            IQueryable<Station> AssociatedStations = null;

            StationRepository SRep = new StationRepository();

            // Setur User ID inn í Klasabreytu
            if (Session != null)
            {
                m_iUserID = Convert.ToInt32(Session["user_id"]);
            }

            OwnedStations = SRep.GetAllOwnedStations(m_iUserID);
            AssociatedStations = SRep.GetAllAssociatedStations(m_iUserID);

            ViewData["owned_stations"] = OwnedStations;
            ViewData["associated_stations"] = AssociatedStations;
        }
    }
}
